package com.smartleanx.module.hrm.util.esign;

import com.smartleanx.module.hrm.util.esign.enums.EsignRequestType;
import com.smartleanx.module.hrm.util.esign.exception.EsignDemoException;

import java.util.Map;

/**
 * E签宝工具包
 *
 * @author xzq
 * @since 2017-06-10 10:10:22
 */
public class ESignUtil {

    //发送请求
    public static EsignHttpResponse sendHttpResponse(String jsonParm, EsignRequestType requestType,String apiaddr,String esignUrl) {
        //生成签名鉴权方式的的header
        String eSignAppId = "7439042143";
        String eSignAppSecret = "77903a458d7fa6a9a4818856966ab1d1";
        try {
            Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId,eSignAppSecret,jsonParm,requestType.name(),apiaddr,true);
            return  EsignHttpHelper.doCommHttp(esignUrl, apiaddr, requestType, jsonParm, header, true);
        } catch (EsignDemoException e) {
            e.printStackTrace();
        }

        return null;
    }



}
